home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / MUI / DEFTII15.LHA / Deft II / Sources / Paths.em < prev    next >
Encoding:
Text File  |  1994-11-06  |  2.4 KB  |  102 lines

  1. OPT MODULE
  2. OPT EXPORT
  3.  
  4.  
  5. ->*****
  6. ->** External modules
  7. ->*****
  8. MODULE 'libraries/mui'
  9. MODULE 'tools/boopsi'
  10. MODULE 'utility/tagitem'
  11. MODULE 'workbench/workbench' , 'workbench/startup'
  12.  
  13. MODULE '*Defs'
  14. MODULE '*GUI_MUIB'
  15. MODULE '*Work'
  16.  
  17.  
  18. ->*****
  19. ->** Global variables
  20. ->*****
  21. DEF deftII                :    PTR TO obj_app
  22. DEF modified            :    LONG
  23. DEF current_edited_path    :    LONG
  24.  
  25.  
  26. /*********************************************************/
  27. /* Adds a path if it isn't already there in the listview */
  28. /*********************************************************/
  29. PROC add_path( path_str : PTR TO CHAR )
  30.  
  31.     DEF already_there = FALSE , i = 0
  32.     DEF path_tmp : PTR TO CHAR
  33.     DEF return = 0
  34.  
  35.     set( deftII.lv_paths , MUIA_List_Quiet , MUI_TRUE )
  36.  
  37.     REPEAT
  38.  
  39.         domethod( deftII.lv_paths , [ MUIM_List_GetEntry , i++ , {path_tmp} ] )
  40.         already_there := str_cmp_no_case( path_str , path_tmp )
  41.  
  42.     UNTIL ( path_tmp = NIL ) OR already_there
  43.  
  44.     IF ( already_there = FALSE ) AND ( StrLen( path_str ) > 0 )
  45.  
  46.         domethod( deftII.lv_paths , [ MUIM_List_InsertSingle , path_str , MUIV_List_Insert_Sorted ] )
  47.         modified := TRUE
  48.  
  49.     ELSE
  50.  
  51.         return := 10
  52.         DisplayBeep( NIL )
  53.  
  54.     ENDIF
  55.  
  56.     current_edited_path := NO_CURRENT_EDITED_PATH
  57.     set( deftII.stR_PA_path , MUIA_String_Contents , '' )
  58.  
  59.     set( deftII.lv_paths , MUIA_List_Quiet , FALSE )
  60.  
  61. ENDPROC return
  62.  
  63.  
  64. /***********************************************************/
  65. /* Prepares the edition of the active path in the listview */
  66. /***********************************************************/
  67. PROC edit_path()
  68.  
  69.     DEF path_str : PTR TO CHAR
  70.  
  71.     get( deftII.lv_paths , MUIA_List_Active , {current_edited_path} )
  72.     domethod( deftII.lv_paths , [ MUIM_List_GetEntry , MUIV_List_GetEntry_Active , {path_str} ] )
  73.     set( deftII.stR_PA_path , MUIA_String_Contents , path_str )
  74.     set( deftII.wi_main , MUIA_Window_ActiveObject , deftII.stR_PA_path )
  75.  
  76. ENDPROC
  77.  
  78.  
  79. /******************************************************/
  80. /* Hook function called to add a path to the listview */
  81. /******************************************************/
  82. PROC app_add_path( hook , obj , msg : PTR TO LONG )
  83.  
  84.     DEF app_paths : PTR TO appmessage
  85.     DEF one_path : PTR TO wbarg
  86.     DEF path_str[ 512 ] : ARRAY OF CHAR , i
  87.  
  88.     app_paths := msg[]
  89.     one_path := app_paths.arglist
  90.  
  91.     FOR i := 1 TO app_paths.numargs
  92.  
  93.         NameFromLock( one_path.lock , path_str , 512 )
  94.         add_path( path_str )
  95.         one_path++
  96.  
  97.     ENDFOR
  98.  
  99.     set( deftII.wi_main , MUIA_Window_ActiveObject , deftII.lv_paths )
  100.  
  101. ENDPROC
  102.